package com.karst.essentials.chapter09
{
	import com.karst.essentials.chapter07.galaxyExample.GalaxyExample;
	
	import flash.display.Sprite;
	
	public class Chapter09View extends Sprite
	{
		public static const SECTION_LIST : Array = 
			["Layering your renders", "ViewportLayerSortMode.Z_SORT排序",
			"ViewportLayerSortMode.INDEX_SORT排序", "四叉树渲染引擎（Quadtree rendering）"
			 ] ;
		
		public function Chapter09View()
		{
			super();
		}
		
		
		public function showSection( $section : String = "" ) : void
		{
			while( numChildren )
				removeChildAt( 0 ) ;
			switch( $section )
			{
				case SECTION_LIST[0] :
					createViewportLayersExample() ;
					break ;
				case SECTION_LIST[1] :
					createViewportLayersGetExample() ;
					break ;
				case SECTION_LIST[2] :
					createViewportLayersIndexSortingExample() ;
					break ;
				case SECTION_LIST[3] :
					createQuadTreeRenderingExample() ;
					break ;
			}
		}

		private var viewportLayersExample : ViewportLayersExample = null ;
		private function createViewportLayersExample() : void
		{
			if( viewportLayersExample == null )
				viewportLayersExample = new ViewportLayersExample() ;
			addChild( viewportLayersExample ) ;
		}

		private var viewportLayersGetExample : ViewportLayersZSortingExample = null ;
		private function createViewportLayersGetExample() : void
		{
			if( viewportLayersGetExample == null )
				viewportLayersGetExample = new ViewportLayersZSortingExample() ;
			addChild( viewportLayersGetExample ) ;
		}

		private var viewportLayersIndexSortingExample : ViewportLayersIndexSortingExample = null ;
		private function createViewportLayersIndexSortingExample() : void
		{
			if( viewportLayersIndexSortingExample == null )
				viewportLayersIndexSortingExample = new ViewportLayersIndexSortingExample() ;
			addChild( viewportLayersIndexSortingExample ) ;
		}

		private var quadTreeRenderingExample : QuadTreeRenderingExample = null ;
		private function createQuadTreeRenderingExample() : void
		{
			if( quadTreeRenderingExample == null )
				quadTreeRenderingExample = new QuadTreeRenderingExample() ;
			addChild( quadTreeRenderingExample ) ;
		}
	}
}